package com.zhixiang.core.command;

import org.hibernate.Criteria;
import org.hibernate.criterion.Example;

public class ExampleCommandImpl
  implements CriteriaCommand
{
  private Object pojoExample;

  public void setPojoExample(Object obj)
  {
    this.pojoExample = obj;
  }

  public ExampleCommandImpl(Object obj)
  {
    this.pojoExample = null;
    this.pojoExample = obj;
  }

  public Criteria execute(Criteria criteria)
  {
    if (this.pojoExample != null)
    {
      Example example = Example.create(this.pojoExample);
      criteria.add(example);
    }
    return criteria;
  }
}

